﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeifenLuo.WinFormsUI.Docking;

namespace SignalBoxSimulator
{
    public class Alerts : DockContent
    {
        private System.Windows.Forms.ListBox lstAlerts;

        public Alerts()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            this.lstAlerts = new System.Windows.Forms.ListBox();
            this.SuspendLayout();
            // 
            // lstAlerts
            // 
            this.lstAlerts.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lstAlerts.FormattingEnabled = true;
            this.lstAlerts.Location = new System.Drawing.Point(0, 0);
            this.lstAlerts.Name = "lstAlerts";
            this.lstAlerts.Size = new System.Drawing.Size(284, 262);
            this.lstAlerts.TabIndex = 0;
            // 
            // Alerts
            // 
            this.ClientSize = new System.Drawing.Size(284, 262);
            this.Controls.Add(this.lstAlerts);
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Name = "Alerts";
            this.TabText = "Alerts";
            this.ResumeLayout(false);

        }

        private List<string> alerts = new List<string>();


        public void AppendAlert(string alertMessage, DateTime alertTime)
        {
            alerts.Insert(0, alertTime.ToString("HH:mm") + " - " + alertMessage);

            while (alerts.Count > 10)
                alerts.RemoveAt(alerts.Count - 1);

            lstAlerts.Items.Clear();
            lstAlerts.Items.AddRange(alerts.ToArray());
        }
    }
}
